/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package interrupted;
import java.util.* ;
import java.lang.* ;
import java.awt.* ;
import java.awt.event.* ;
import javax.swing.* ;
import Widgets.*;

/**
 *
 * @author Mdbrown
 */
public class VisualSuspendResume extends JPanel implements Runnable{

    private static final String [] symbolList = {"|","/","-","\\","|","/","-","\\"};
    private Thread runThread = null ;
    private JTextField symbolTF = null ;

    private JButton suspendb = null;
    private JButton resumeb = null ;

    private JPanel innerStackP = new JPanel() ;

    //private innerStackP isp = null ; 
    private JPanel isp = null;


    public VisualSuspendResume(){
        symbolTF = new JTextField() ;
        symbolTF.setEditable(false);
        symbolTF.setFont(new Font("MonoSpaced",Font.BOLD,26));
        symbolTF.setHorizontalAlignment(JTextField.CENTER);
       // isp = new innerStackP() ;
        isp = new JPanel() ;
        suspendb =  new suspendB("Suspend Button ",runThread );
        suspendb.addActionListener(null) ;
        resumeb = new resumeB("Resume Button", runThread) ;
        resumeb.addActionListener(null);
        isp.setLayout(new GridLayout(0,1,3,3));
        isp.add(symbolTF);
        isp.add(suspendb);
        isp.add(resumeb);
        this.add(isp);



       // innerStackP.setLayout(new GridLayout(0,1,3,3));


        /*
        this.add(suspendb);
        this.add(resumeb);
        */


    }//end of class  VisualSuspendResume()


    public void run(){
        try{
            runThread = Thread.currentThread(); //set pointer to current Thread
            int count = 0 ;

            while(true){
                symbolTF.setText(symbolList[count % symbolList.length]); //set text based on modulo index of symbolList array
                Thread.sleep(100); //current Thread sleep
                count++ ;
            }//end of while

        }catch(InterruptedException x){
            //pass
        }finally{

                runThread = null ;
        }//end of try-catch-finally clause

    }//end of run() override

}//end interruptedClass
